/*
 *
 * System2 Simulation Framework
 * Copyright (C) 2011 - 2012 Jacob Dawid
 * jacob.dawid@googlemail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef VALUE_H
#define VALUE_H

#include "unit.h"
#include <QString>

namespace System2 {
    /**
      * \class Value
      * \author Jacob Dawid <jacob.dawid@googlemail.com>
      * \date 16.01.2012
      */
    class Value {
    public:
        Value();
        Value(Number number, Unit unit);
        Value(const Value& other);

        QString toString();
        bool translateToUnit(const Unit& unit);
        bool isValid() const;

        void assign(const Value& other);
        void assign(Number number, Unit unit);
        bool isEqualTo(const Value& other);

        void add(const Value& other);
        void subtract(const Value& other);
        void multiply(Number number);
        void divide(Number number);

        const Value& operator =(const Value& other) {
            assign(other);
            return *this;
        }

        const Value& operator +(const Value& other) {
            add(other);
            return *this;
        }

        const Value& operator -(const Value& other) {
            subtract(other);
            return *this;
        }

    private:
        Number m_number;
        Unit m_unit;
        bool m_isValid;
    };
}

#endif // VALUE_H
